levelbar: Don't allocate 0 blocks
authorTimm Bäder <mail@baedert.org>
Sun, 30 Apr 2017 18:19:56 +0000 (20:19 +0200)
committerTimm Bäder <mail@baedert.org>
Sun, 30 Apr 2017 18:22:25 +0000 (20:22 +0200)
Could result in a division by zero later on and doesn't make a lot of
sense anyway.

gtk/gtklevelbar.c

index d1b25b398034365ad6d8c30887db3d1c233aa096..6cc32e4e549de0234716afd35ae5271f69382407 100644 (file)
@@ -480,6 +480,9 @@ gtk_level_bar_allocate_trough_discrete (GtkLevelBar *self,
   gtk_level_bar_get_min_block_size (self, &block_width, &block_height);
   num_blocks = gtk_level_bar_get_num_blocks (self);
 
+  if (num_blocks == 0)
+    return;
+
   if (self->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       block_width = MAX (block_width, (gint) floor (allocation->width / num_blocks));